package com.travel.recommend.controller;

import java.util.Arrays;
import java.util.Map;

import com.travel.common.to.AttractionInfoTo;
import com.travel.common.to.UpdateUserAttractionWeightTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.travel.recommend.entity.UserAttractionWeightEntity;
import com.travel.recommend.service.UserAttractionWeightService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2024-01-23 15:41:41
 */
@RestController
@RequestMapping("recommend/userattractionweight")
public class UserAttractionWeightController {
    @Autowired
    private UserAttractionWeightService userAttractionWeightService;

    /**
     * 更新用户对该景点的权重
     */
    @RequestMapping("/updateUserAttractionWeight/{userId}")
    public R updateUserAttractionWeight(@RequestBody UpdateUserAttractionWeightTo to, @PathVariable("userId")Integer userId){
        userAttractionWeightService.updateUserAttractionWeight(to,userId);

        return R.ok();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("recommend:userattractionweight:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userAttractionWeightService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userAttractionTagId}")
    //@RequiresPermissions("recommend:userattractionweight:info")
    public R info(@PathVariable("userAttractionTagId") Integer userAttractionTagId){
		UserAttractionWeightEntity userAttractionWeight = userAttractionWeightService.getById(userAttractionTagId);

        return R.ok().put("userAttractionWeight", userAttractionWeight);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("recommend:userattractionweight:save")
    public R save(@RequestBody UserAttractionWeightEntity userAttractionWeight){
		userAttractionWeightService.save(userAttractionWeight);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("recommend:userattractionweight:update")
    public R update(@RequestBody UserAttractionWeightEntity userAttractionWeight){
		userAttractionWeightService.updateById(userAttractionWeight);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("recommend:userattractionweight:delete")
    public R delete(@RequestBody Integer[] userAttractionTagIds){
		userAttractionWeightService.removeByIds(Arrays.asList(userAttractionTagIds));

        return R.ok();
    }

}
